package com.cxyd.modules.wms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cxyd.common.service.impl.CrudServiceImpl;
import com.cxyd.modules.wms.dao.ZoneDao;
import com.cxyd.modules.wms.dto.ZoneDTO;
import com.cxyd.modules.wms.entity.ZoneEntity;
import com.cxyd.modules.wms.service.ZoneService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ZoneServiceImpl extends CrudServiceImpl<ZoneDao, ZoneEntity, ZoneDTO> implements ZoneService {

    @Override
    public QueryWrapper<ZoneEntity> getWrapper(Map<String, Object> params) {
        String contNo = (String) params.get("zoneNo");
        String trkType = (String) params.get("zoneName");
        String dvcNo = (String) params.get("zoneType");
        String frmPos = (String) params.get("zoneSt");
        QueryWrapper<ZoneEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(dvcNo), "zone_no", dvcNo);
        wrapper.eq(StringUtils.isNotBlank(trkType), "zone_type", trkType);
        wrapper.eq(StringUtils.isNotBlank(frmPos), "zone_name", frmPos);
        wrapper.like(StringUtils.isNotBlank(contNo), "zone_st", contNo);
        return wrapper;
    }

    @Override
    public ZoneEntity getByZoneNo(String zoneNo) {
        QueryWrapper<ZoneEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("zone_no", zoneNo);
        return baseDao.selectOne(wrapper);
    }
}